package main

import "fmt"

func main() {
	appendElement4Slice(false)

}

func appendElement4Slice(withCopyTest bool) {

	mySlice := make([]string, 2)
	mySlice[0] = "slice-1"
	mySlice[1] = "slice-1"
	fmt.Println("len=", len(mySlice))
	fmt.Println("cap=", cap(mySlice))
	mySlice = append(mySlice, "addedSlice")
	fmt.Println(mySlice)
	fmt.Println("After len=", len(mySlice))
	fmt.Println("After cap=", cap(mySlice))
	fmt.Printf(`%T`, mySlice)

	//copy some new data from `src` to `mySlice`
	if withCopyTest {
		src := make([]string, 1)
		src[0] = "newData"
		copy(mySlice, src)
		fmt.Println("after copy:", mySlice)
	}
}
